<?php
/**
 * provide common methods to its subclasses
 *
 * @author     ben
 */
abstract class WacStatsAction extends sfAction
{
    /*
     * get date periods according to the request params
     * @return array
     */
    public function getPeriods($request, $interval='month')
    {
        $periods = DatePeriod::getPeriods(false, $interval);

        return $periods;
    }

    public function _outputBar3DSWFTest($request)
    {
        //Create new stBar3D object and set the transparency and colour.
		$redBar = new stBar3D( 75, '#d01f3c' );
		$redBar->key( '2007', 10 );

		//random data
		for( $i = 0; $i < 12; $i++ )
		{
			$redBar->data[] = rand(200,500);
		}

		//2nd Bar
		$blueBar = new stBar3D( 75, '#356aa0' );
		$blueBar->key( '2008', 10 );

		//random data for 2nd bar
		for( $i = 0; $i < 12; $i++ )
		{
			$blueBar->data[] = rand(200,500);
		}

        //3nd Bar
		$greenBar = new stBar3D( 75, '#80FF00' );
		$greenBar->key( '2009', 10 );

		//random data for 3nd bar
		for( $i = 0; $i < 12; $i++ )
		{
			$greenBar->data[] = rand(200,500);
		}

		$g = new stGraph();
		$g->bg_colour = '#E4F5FC';
		$g->title( 'Number of downloads in 2008 and 2009', '{font-size:20px; color: #18A6FF;}' );

		$g->data_sets[] = $redBar;
		$g->data_sets[] = $blueBar;
                $g->data_sets[] = $greenBar;

		//to create 3d x-axis
		$g->set_x_axis_3d( 10 );
		$g->x_axis_colour( '#8499A4', '#E4F5FC' );
		$g->y_axis_colour( '#8499A4', '#E4F5FC' );

//		$g->set_x_labels( array( 'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct', 'Nov', 'Dec' ) );
                $g->set_x_labels( array( '1月','2月','3月','4月','5月','6月','7月','8月','9月','10月', '11月', '12月' ) );
		$g->set_y_max( 500 );
		$g->y_label_steps( 5 );
		$g->set_y_legend( 'stOfcPlugin', 12, '#18A6FF' );
		echo $g->render();

		return sfView::NONE;
    }
}
